<template>
	<view class="container" v-if="isData">
		<!-- 导航栏 -->
		<!-- <clockScoll :navList="navList"></clockScoll> -->
		<!-- 打卡列表 -->
		<view class="list">
			<clockList :dataList="dataList" :isClockBtn="false" :isUpdateBtn="false"></clockList>
		</view>
	</view>
	<view class="container" v-else>
		无关系数据
	</view>
	<uni-load-more :status="status" :content-text="contentText" @clickLoadMore="onLoadList()" />
</template>

<script>
	import store from '@/store/index.js'; //需要引入store
	import {
		publicFinishTaskList
	} from '@/api/api.js'
	export default {
		data() {
			return {
				listReq: {
					pageInfo: {
						page: 1,
						size: 5,
					}
				},
				status: 'more',
				contentText: {
					contentdown: '点击查看更多',
				},
				isData: true,
				navList: ['全部', '每日', '周末限定', '节日限定'],
				activeNavIndex: 0,
				dataList: []
			}
		},
		onLoad() {
			this.loadList()
		},
		onTabItemTap() {
			if (this.dataList.length > 0) {
				uni.reLaunch({
					url: '/pages/clock/list'
				});
			}

		},
		methods: {
			onLoadList() {
				this.status = 'loading'
				this.listReq.pageInfo.page += 1
				this.loadList()
			},
			loadList() {
				publicFinishTaskList(this.listReq).then(res => {
					console.log(res.data)
					if (res.data.code != 0) {
						this.listReq.pageInfo.page -= 1
						this.status = 'noMore'
						uni.showToast({
							icon: "none",
							title: res.data.message
						})
					} else {
						var data = res.data.data
						let list = this.dataList
						this.dataList = list.concat(data.list)
						if (data.page_info.total_page - this.listReq.pageInfo.page <= 0) {
							this.status = 'noMore'
						} else {
							this.status = 'more'
						}
					}

				})
			}
		}
	}
</script>
<style>
	.container {
		display: flex;
		flex-direction: column;
		padding: 20upx;
	}

	.list {
		width: 100%;
	}
</style>